var path = require("path");
var htmlWebpackPlugin = require("html-webpack-plugin");
const { VueLoaderPlugin } = require("vue-loader"); //vue-loader-plugin 不引入报错

module.exports = {
  entry: path.join(__dirname, "./src/main.js"), //入口文件路径
  output: {
    path: path.join(__dirname, "./dist"), //输入文件路径
    filename: "bundle.js" //输出文件名字
  },
  plugins: [
    new htmlWebpackPlugin({
      template: path.join(__dirname, "./src/index.html"), //指定模板路径
      filename: "index.html" //生成在内存中页面名字
    }),
    new VueLoaderPlugin() //vue-loader-plugin 不引入报错
  ],
  module: {
    rules: [
      { test: /\.css$/, use: ["style-loader", "css-loader"] }, //css规则
      { test: /\.vue$/, use: "vue-loader" }, //vue配置规则
      { test: /\.sass$/, use: ["style-loader", "css-loader", "sass-loader"] }, //配置sass
      { test: /\.less$/, use: ["style-loader", "css-loader", "less-loader"] }, //配置less
      {
        test: /\.(jpg|png|gif|bmp|jpeg)$/,
        use: "url-loader?limit=7000&name=[name].[ext]"
      }, //图片规则
      { test: /\.js$/, use: "babel-loader", exclude: /node_modules/ }, //配置babel解析es6语言
      { test: /\.(ttf|eot|svg|woff|woff2)$/, use: "url-loader" } //添加字体文件配置
    ]
  }
  // resolve:{
  //     alias:{ //修改vue路径，选择完整包n
  //         "vue$":"vue/dist/vue.js"
  //     }
  // }
};
